<style type="text/css">
    .side-right {
        width: 750px;
        display: inline-block;
        vertical-align: top;
        padding-left: 1em;
        overflow: hidden;
    }

    .side-left {
        width: 150px;
        display: inline-block;
        vertical-align: top;
        padding-right: 1em;
    }

    .side-right .title {
    }

    .userprofile {

    }

    #userpic {
        height: 140px;
        width: 120px;
        border: 1px solid black;
        margin: 0.96em auto;
        background-image: url("<?php echo $loggedUser->display_pic->src; ?>");
    }

    #userpic:hover {
        border-color: red;
        cursor: pointer;
    }

    ul.actions-main {
        font-weight: bold;
        list-style: none;
        padding-left: 0em;
        margin-top: 1em;
    }

    ul.actions-main li {
        font-size: 1em; /* 12px */
        line-height: 1.5000em; /* 18px */
        margin: 0;
    }

    ul.actions-sub {
        font-weight: normal;
        margin: 0;
        padding-left: 1.5em;
    }

    ul.actions-sub li {
        list-style-type: circle;
    }

</style>
<div class="side-left">
    <div class="userprofile">
        <div class="username title"><?php echo $loggedUser->display_name; ?></div>
        <div id="userpic" class="img-uploader makethumb" afterupload="updateUserPic();"></div>
        <form class="img-uploader" action="<?php echo site_url("service/imageupload/userpic/1/60/70"); ?>" method="post" enctype="multipart/form-data"></form>
        <div class="userid" style="margin-bottom: 0.3em;">
            User ID : <?php echo $loggedUser->id; ?>
            [ <a href='<?php echo site_url("login/doLogout"); ?>'>Logout</a> ]
        </div>
        <div class="userdate">
            Terdaftar :
            <?php echo $loggedUser->register_date; ?>
        </div>
    </div>
    <div class="actions">
        <hr />
        <ul class="actions-main">
            <li>
                Pengaturan Profil
                <ul class='actions-sub'>
                    <li><a href="<?php echo site_url("usercp/detail"); ?>">Detail User</a></li>
                    <li><a href="<?php echo site_url("usercp/password"); ?>">Ubah Password</a></li>
                </ul>
            </li>
            <?php
            if (count(array_intersect(Array(
                        "gal_contributor",
                        "gal_auditor",
                        "master_admin"
                                    ), $loggedUser->roles)) > 0) {
                echo "<li>" . "Galeri";
                echo "<ul class='actions-sub'>";
                if (in_array("gal_contributor", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/uploadgal/img") . "'>" . "Upload Gambar" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/uploadgal/vid") . "'>" . "Upload Video" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/historygal") . "'>" . "History" . "</a>" . "</li>";
                }
                if (in_array("gal_auditor", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/auditgal") . "'>" . "Audit entry galeri" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/hlgal") . "'>" . "Pilih highlight galeri" . "</a>" . "</li>";
                }
                if (in_array("gal_auditor", $loggedUser->roles) || (in_array("master_admin", $loggedUser->roles))) {
                    echo "<li>" . "<a href='" . site_url("usercp/editgal") . "'>" . "Hapus entry galeri" . "</a>" . "</li>";
                }
                echo "</ul>";
                echo "</li>";
            }
            if (count(array_intersect(Array(
                        "kegiatan_contributor",
                        "kegiatan_auditor",
                        "master_admin"
                                    ), $loggedUser->roles)) > 0) {
                echo "<li>" . "Kegiatan";
                echo "<ul class='actions-sub'>";
                if (in_array("kegiatan_contributor", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/addkegiatan") . "'>" . "Input kegiatan" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/addberitakegiatan") . "'>" . "Input berita kegiatan" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/historykegiatan") . "'>" . "History entry kegiatan" . "</a>" . "</li>";
                }
                if (in_array("kegiatan_auditor", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/auditkegiatan") . "'>" . "Audit entry kegiatan" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/hlkegiatan") . "'>" . "Pilih highlight kegiatan" . "</a>" . "</li>";
                }
                if (in_array("master_admin", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/editkegiatan") . "'>" . "Edit entry kegiatan" . "</a>" . "</li>";
                }
                echo "</ul>";
                echo "</li>";
            }
            if (count(array_intersect(Array(
                        "berita_contributor",
                        "berita_auditor",
                        "master_admin"
                                    ), $loggedUser->roles)) > 0) {
                echo "<li>" . "Berita PS";
                echo "<ul class='actions-sub'>";
                if (in_array("berita_contributor", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/addartikel/b") . "'>" . "Input berita PS" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/historyartikel/b") . "'>" . "History entry berita PS" . "</a>" . "</li>";
                }
                if (in_array("berita_auditor", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/auditartikel/b") . "'>" . "Audit entry berita PS" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/hlartikel/b") . "'>" . "Pilih highlight berita PS" . "</a>" . "</li>";
                }
                if (in_array("master_admin", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/editartikel/b") . "'>" . "Edit entry berita PS" . "</a>" . "</li>";
                }
                echo "</ul>";
                echo "</li>";
            }
            if (count(array_intersect(Array(
                        "kr_contributor",
                        "kr_auditor",
                        "master_admin"
                                    ), $loggedUser->roles)) > 0) {
                echo "<li>" . "Kabar Relawan";
                echo "<ul class='actions-sub'>";
                if (in_array("kr_contributor", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/addartikel/kr") . "'>" . "Tulis artikel" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/historyartikel/kr") . "'>" . "History entry artikel" . "</a>" . "</li>";
                }
                if (in_array("kr_auditor", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/auditartikel/kr") . "'>" . "Audit entry artikel" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/hlartikel/kr") . "'>" . "Pilih highlight artikel" . "</a>" . "</li>";
                }
                if (in_array("master_admin", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/editartikel/kr") . "'>" . "Edit entry artikel" . "</a>" . "</li>";
                }
                echo "</ul>";
                echo "</li>";
            }
            if (count(array_intersect(Array(
                        "pj_contributor",
                        "pj_auditor",
                        "master_admin"
                                    ), $loggedUser->roles)) > 0) {
                echo "<li>" . "Jurnalisme Publik";
                echo "<ul class='actions-sub'>";
                if (in_array("pj_contributor", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/addartikel/pj") . "'>" . "Tulis artikel" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/historyartikel/pj") . "'>" . "History entry artikel" . "</a>" . "</li>";
                }
                if (in_array("pj_auditor", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/auditartikel/pj") . "'>" . "Audit entry artikel" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/hlartikel/pj") . "'>" . "Pilih highlight artikel" . "</a>" . "</li>";
                }
                if (in_array("master_admin", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/editartikel/pj") . "'>" . "Edit entry artikel" . "</a>" . "</li>";
                }
                echo "</ul>";
                echo "</li>";
            }
            if (count(array_intersect(Array(
                        "bulletin_master"
                                    ), $loggedUser->roles)) > 0) {
                echo "<li>" . "Buletin";
                echo "<ul class='actions-sub'>";
                if (in_array("bulletin_master", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/addpub/buletin") . "'>" . "Upload buletin" . "</a>" . "</li>";
                    echo "<!--li>" . "<a href='" . site_url("usercp/managepub/buletin") . "'>" . "Manage buletin" . "</a>" . "</li-->";
                }
                echo "</ul>";
                echo "</li>";
            }

            if (count(array_intersect(Array(
                        "data_entry",
                        "data_master"
                                    ), $loggedUser->roles)) > 0) {
                echo "<li>" . "Data EntryPS";
                echo "<ul class='actions-sub'>";
                if (in_array("data_entry", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/data/entry") . "'>" . "Data entry" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/data/spasial") . "'>" . "Spasial" . "</a>" . "</li>";
                }
                if (in_array("data_master", $loggedUser->roles)) {
                    //echo "<li>" . "<a href='" . site_url("usercp/data/form") . "'>" . "Edit form data entry" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/data/indicator") . "'>" . "Edit indikator" . "</a>" . "</li>";
                    echo "<li>" . "<a href='javascript:void(0);' onClick='javascript:window.open(\"" . site_url("usercp/indicatortree") . "\");' >" . "Lihat overview indikator" . "</a>" . "</li>";
                }
                echo "</ul>";
                echo "</li>";
            }
            if (count(array_intersect(Array(
                        "master_admin"
                                    ), $loggedUser->roles)) > 0) {
                echo "<li>" . "User Management";
                echo "<ul class='actions-sub'>";
                if (in_array("master_admin", $loggedUser->roles)) {
                    echo "<li>" . "<a href='" . site_url("usercp/user/acc") . "'>" . "Pengaturan user" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/user/groups") . "'>" . "Pengaturan user group" . "</a>" . "</li>";
                    echo "<li>" . "<a href='" . site_url("usercp/user/roles") . "'>" . "Pengaturan user role" . "</a>" . "</li>";
                }
                echo "</ul>";
                echo "</li>";
            }
            ?>
        </ul>
    </div>
</div>
<div class="side-right">
    <h1 class="title"><?php echo $pageTitle; ?></h1>
    <?php
    $this->view("usercp/" . $page);
    ?>
</div>
<script type="text/javascript">
    function updateUserPic() {
        var tempPicName = $("#userpic input[type='hidden']").val();
        $.ajax({
            type: "POST",
            url: "<?php echo site_url("usercp/updatePic"); ?>",
            data: {tempfilename: tempPicName},
            beforeSend: function(xhr) {
            },
            success: function(result, status, xhr) {
                if (result) {
                    window.location = "<?php echo site_url("usercp"); ?>";
                }
            },
            error: function(xhr, status, error) {
            }
        });
    }
    ;
</script>